package com.dailyblue.project.estate.pet.controller;

import com.dailyblue.project.estate.commons.bean.Pet;
import com.dailyblue.project.estate.commons.bean.Repair;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.pet.service.PetService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pet")
public class PetController {
    @Resource
    private PetService petService;

    @PostMapping
    public JsonResult save(Pet pet) {
        return petService.addPet(pet);
    }

    @GetMapping("/findOne/{id}")
    JsonResult findOne(@PathVariable("id") String id) {
        return petService.findOnePet(id);
    }

    @GetMapping
    public JsonResult findAll() {
        return petService.findAllPets();
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult delete(@PathVariable("id") String id) {
        return petService.deletePet(id);
    }

    @PutMapping("/update")
    public JsonResult update(@RequestBody Pet pet) {
        return petService.updatePet(pet);
    }
}
